﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Universitario.DAO;

namespace Universitario
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void register_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/RegisterAluno.aspx");

        }

        protected void btLogin_Click(object sender, EventArgs e)
        {
            Usuario usuario = UsuarioDAO.Login(TxtUser1.Text,TxtPass1.Text);
            if (usuario != null)
            {
                Session.Add("Usuario",usuario);
                Response.Redirect("~");
            }
            else
            {
                ClientScript.RegisterStartupScript(typeof(Login), "MyScript", "<script language=\"text/javascript\"> alert('Senha ou CPF inválidos')</script>");
            }
        }
    }
}